package com.immac.leejc.serializable;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class TestMain {
	public static void print() {
		LeeJCSerializable ljcSerializable = new LeeJCSerializable();
		byte[] bytes = ljcSerializable.serialize();
		
		for (int i = 0; i < bytes.length; i++) {
			System.out.println(bytes[i]);
		}
	}

	public static void writeFile() throws IOException {
		LeeJCSerializable ljcSerializable = new LeeJCSerializable();
		byte[] bytes = ljcSerializable.serialize();
		
		File file = new File("text/Serializable.txt");
		FileOutputStream fileOutputStream = new FileOutputStream(file);
		fileOutputStream.write(bytes);
		
		fileOutputStream.close();
		System.out.println("write file close");
	}

	public static void readFile() throws IOException {
		LeeJCSerializable ljcSerializable = new LeeJCSerializable();
		byte[] bytes = new byte[4096];
		
		File file = new File("text/Serializable.txt");
		FileInputStream fileInputStream = new FileInputStream(file);
		fileInputStream.read(bytes);

		ljcSerializable.printAllData();
		ljcSerializable.setZero();
		ljcSerializable.printAllData();
		ljcSerializable.deserialize(bytes);
		ljcSerializable.printAllData();
		
		fileInputStream.close();
		System.out.println("read file close");
	}
}
